from typing import List, Any

from myapp.pp_py.src.config.config import PPConfig
from myapp.pp_py.src.data_structures.attribute_structures import Water, Vegetation, Building, Soil, DemAttribute
from myapp.pp_py.src.data_structures.base_structures import Map, HexCell


def get_grids_info(h3indexes: List[Any]):
    map:Map = PPConfig.global_map
    cells_attrs = []
    for h3index in h3indexes:
        cell:HexCell = map.cells[h3index]
        dict = {}
        dict["h3index"] = h3index
        if cell.has_attribute(Water):
            dict["attribute"] = "Water"
            dict["color"] = "#0000FF"
        if cell.has_attribute(Building):
            dict["attribute"] = "Building"
            dict["color"] = "#423c3f"
        if cell.has_attribute(Vegetation):
            dict["attribute"] = "Vegetation"
            dict["color"] = "#22ff00"
        if cell.has_attribute(Soil):
            dict["attribute"] = "Soil"
            dict["color"] = "#91952f"
        if cell.has_attribute(DemAttribute.Slope):
            dict["slope"] = cell.get_attribute(DemAttribute.Slope).get_value()
        else:
            dict["slope"] = 0
        cells_attrs.append(dict)
    return cells_attrs